
#include "stdafx.h"
#include "Packet.h"
#include "PacketFactory.h"


PacketFactory::PacketFactory()
{
	m_pPacketPool		= new CMemoryPoolFactory<Packet>;
	
}

PacketFactory::~PacketFactory()
{
	delete m_pPacketPool;
}

VOID PacketFactory::Release()
{
	m_pPacketPool->Release();
}

VOID PacketFactory::Init( DWORD dwSize )
{
	m_pPacketPool->Initialize( dwSize, dwSize/2+1 );
}

Packet* PacketFactory::Alloc()
{
	Packet *pPacket = m_pPacketPool->Alloc();
    //init
	pPacket->init();
	return pPacket;
}

VOID PacketFactory::Free( Packet* pPacket )
{   
	pPacket->release();
	m_pPacketPool->Free(pPacket);
}

